Skip to content

FEAT add TargetRequirements#1582

Merged
hannahwestra25 merged 5 commits intomicrosoft:mainfrom
hannahwestra25:hawestra/add_target_requirements
Apr 10, 2026
Merged

FEAT add TargetRequirements#1582
hannahwestra25 merged 5 commits intomicrosoft:mainfrom
hannahwestra25:hawestra/add_target_requirements

Conversation

@hannahwestra25
Copy link
Copy Markdown
Contributor

Description

Adds TargetRequirements, the consumer-side counterpart to TargetConfiguration. Useful for consumers (attacks, converters, scorers) to validate their requirements against a target's configuration at construction time. TargetRequirements is the mechanism for that — a frozen, declarative description of what capabilities a consumer needs, validated in a single call.

for example, a CrescendoAttack would use requirements :

 class CrescendoAttack:
    REQUIREMENTS = TargetRequirements(
        required_capabilities=frozenset({
            CapabilityName.MULTI_TURN,
            CapabilityName.SYSTEM_PROMPT,
        })
    )


    def __init__(self, *, objective_target: PromptTarget, ...) -> None:
        # Validates all requirements in one call — fails fast with all violations
        self.REQUIREMENTS.validate(configuration=objective_target.configuration)

If the target natively supports the capabilities, validation passes. If not, the TargetConfiguration's CapabilityHandlingPolicy is consulted — if the policy is ADAPT, normalization will handle it; if RAISE (or no policy exists), validate() collects all violations and raises a single ValueError eg:
ValueError: Target does not satisfy 2 required capability(ies):

  • Target does not support 'supports_multi_turn' and the handling policy is RAISE.
  • Target does not support 'supports_system_prompt' and no handling policy exists for it.

Tests and Documentation

Copy link
Copy Markdown
Contributor

@ValbuenaVC ValbuenaVC left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two nits, looks good!

@hannahwestra25 hannahwestra25 merged commit 3104bdc into microsoft:main Apr 10, 2026
38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants